const util = require('../../../utils/util.js');
const api = require('../../../config/api.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    product: [],
    imgs: [],
    indicatorDots: true,
    autoplay: false,
    interval: 5000,
    duration: 1000
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    if (options.id) {
      that.setData({
        id: options.id
      });
    }

    that.getProductData();

  },
  getProductData: function() {
    let that = this;
    util.request(api.ProductDetailUrl, {
      id: that.data.id
    }).then(function(res) {
      if (res.success) {
        let content = res.data.content;
        that.setData({
          product: res.data,
          imgs: res.data.imgs
        });
      }
    });
  },
  buyOrder: function() {
    let that = this;
    let url = '';
    util.isLogin('/pages/goods/order/order?pid=' + that.data.product.id);
  },
  toTel:function(){
    wx.makePhoneCall({
      phoneNumber: '0871-68315686',
    })
  }
})